﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using QuanLyDuAn.BUS;
using System.Data.SqlClient;
using QuanLyDuAn.Report;

namespace QuanLyDuAn.GUI
{
    public partial class FrmStaticInterviewPlan : DevComponents.DotNetBar.Office2007Form
    {
        DataSet ds;
        InterviewPlanController InterviewPlan = new InterviewPlanController();
        String year = DateTime.Now.Year.ToString();
        public FrmStaticInterviewPlan()
        {
            InitializeComponent();
        }

        private void FrmStaticInterviewPlan_Load(object sender, EventArgs e)
        {
            this.dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
            ds = InterviewPlan.LoadInterviewPlan();
            dataGridViewX1.DataSource = ds.Tables[0];
            cmbQuater.Items.Add("Quarter I");
            cmbQuater.Items.Add("Quarter II");
            cmbQuater.Items.Add("Quarter III");
            cmbQuater.Items.Add("Quarter IV");
        }

        private void btnPreview_Click(object sender, EventArgs e)
        {
            if (cmbQuater.Text.CompareTo("") != 0)
            {
                String quarter = cmbQuater.SelectedItem.ToString();
                if (quarter.CompareTo("Quarter I") == 0)
                {
                    String date1 = "1/1/" + year;
                    String date2 = "3/31/" + year;
                    FrmSttInterviewPlan frm = new FrmSttInterviewPlan();
                    frm.datetime1 = date1;
                    frm.datetime2 = date2;
                    frm.Visible = true;
                    frm.Show();

                }
                if (quarter.CompareTo("Quarter II") == 0)
                {
                    String date1 = "4/1/" + year;
                    String date2 = "6/30/" + year;
                    FrmSttInterviewPlan frm = new FrmSttInterviewPlan();
                    frm.datetime1 = date1;
                    frm.datetime2 = date2;
                    frm.Visible = true;
                    frm.Show();

                }
                if (quarter.CompareTo("Quarter III") == 0)
                {
                    String date1 = "7/1/" + year;
                    String date2 = "9/31/" + year;
                    FrmSttInterviewPlan frm = new FrmSttInterviewPlan();
                    frm.datetime1 = date1;
                    frm.datetime2 = date2;
                    frm.Visible = true;
                    frm.Show();

                }
                if (quarter.CompareTo("Quarter IV") == 0)
                {
                    String date1 = "10/1/" + year;
                    String date2 = "12/31/" + year;
                    FrmSttInterviewPlan frm = new FrmSttInterviewPlan();
                    frm.datetime1 = date1;
                    frm.datetime2 = date2;
                    frm.Visible = true;
                    frm.Show();

                }
            }
            else
            {
                MessageBox.Show("Please select quarer !");
            }
        }

        private void cmbQuater_SelectedIndexChanged(object sender, EventArgs e)
        {
            String quarter = cmbQuater.SelectedItem.ToString();
            if (quarter.CompareTo("Quarter I") == 0)
            {
                String date1 = "1/1/" + year;
                String date2 = "3/31/" + year;
                ds = new DataSet();
                ds = InterviewPlan.StatisticsInterviewPlan(date1, date2);
                dataGridViewX1.DataSource = ds.Tables[0];
            }
            if (quarter.CompareTo("Quarter II") == 0)
            {
                String date1 = "4/1/" + year;
                String date2 = "6/30/" + year;
                ds = new DataSet();
                ds = InterviewPlan.StatisticsInterviewPlan(date1, date2);
                dataGridViewX1.DataSource = ds.Tables[0];
            }
            if (quarter.CompareTo("Quarter III") == 0)
            {
                String date1 = "7/1/" + year;
                String date2 = "9/30/" + year;
                ds = new DataSet();
                ds = InterviewPlan.StatisticsInterviewPlan(date1, date2);
                dataGridViewX1.DataSource = ds.Tables[0];
            }
            if (quarter.CompareTo("Quarter IV") == 0)
            {
                String date1 = "10/1/" + year;
                String date2 = "12/31/" + year;
                ds = new DataSet();
                ds = InterviewPlan.StatisticsInterviewPlan(date1, date2);
                dataGridViewX1.DataSource = ds.Tables[0];
            }
        }
    }
}
